package binaryTree;

// 进行测试

public class TestDemo {
    public static void main(String[] args) {
        BinaryTree binaryTree = new BinaryTree();
        System.out.println("穷举法创建二叉树：");
        binaryTree.createTree();

        System.out.println("前序遍历：");
        binaryTree.preOrder(binaryTree.root);

        System.out.println("中序遍历：");
        binaryTree.inOrder(binaryTree.root);

        System.out.println("后序遍历：");
        binaryTree.postOrder(binaryTree.root);

        System.out.println("获取树中结点的个数：（子问题递归法）");
        System.out.println(binaryTree.size(binaryTree.root));
        System.out.println("获取树中结点的个数：（遍历+static全局变量）");
        System.out.println(BinaryTree.countNode); // 注意static全局变量引用方式

        System.out.println("获取叶子结点个数：（子问题递归）");
        System.out.println(binaryTree.getLeafNodeCount(binaryTree.root));
        System.out.println("获取树中叶子结点的个数：（遍历+static全局变量）");
        System.out.println(BinaryTree.leafCount);

        System.out.println("获取第3层结点的个数:");
        System.out.println(binaryTree.getKLevelNodeCount(binaryTree.root, 3));

        System.out.println("获取二叉树的高度：即最大深度:");
        System.out.println(binaryTree.getHeight(binaryTree.root));

        System.out.println("检测值为H的结点是否存在:");
        System.out.println(binaryTree.find(binaryTree.root, 'H'));

        System.out.println("检测值为I的结点是否存在:");
        System.out.println(binaryTree.find(binaryTree.root, 'I'));

        System.out.println("层序遍历：");
        binaryTree.levelOrder(binaryTree.root);

        // 注意该方法：重要！！！--区分每一层
        System.out.println("层序遍历2：双层链表：");
        System.out.println(binaryTree.levelOrder2(binaryTree.root));

        System.out.println("判断是否为完全二叉树：");
        System.out.println(binaryTree.isCompleteTree(binaryTree.root));
    }
}
